package org.esk.dablog.web.forms.forum;

import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.ModelAndView;
import org.esk.dablog.service.EntryManager;
import org.esk.dablog.model.forum.ForumTopicEntry;
import org.esk.dablog.model.Entry;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * This class implements "View Forum Topics List" task 
 * User: esk
 * Date: Dec 12, 2006
 * Time: 3:04:25 PM
 * $Id:$
 */
public class ListTopicsForm extends ParameterizableViewController {

    private EntryManager entryManager;


    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        List topics = entryManager.listEntries(ForumTopicEntry.class);
        ModelAndView mav =  super.handleRequestInternal(request, response);
        mav.addObject("entries", topics);
        return mav;
    }


    public void setEntryManager(EntryManager entryManager) {
        this.entryManager = entryManager;
    }
}
